<div class="layui-card">
    {{--<fieldset class="layui-elem-field">--}}
        {{--<div class="layui-field-box">--}}
            {{--<a class="layui-btn-sm" style="cursor:pointer;" onclick="reload('{:url('Index/home')}');">首页</a>&raquo;--}}
            {{--<a class="layui-btn-sm" style="cursor:pointer;" onclick="reload('{:url('Goods/index')}');">商品列表</a>&raquo;--}}
            {{--<a class="layui-btn-sm" style="cursor:pointer;" onclick="refresh();" >其余主图</a>--}}
        {{--</div>--}}
    {{--</fieldset>--}}

    <blockquote class="layui-elem-quote layui-quote-nm">
        商品名: {$gname}
    </blockquote>

    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            {empty name="piclist"}
            该商品还没有添加其余主图
            {else /}
            {foreach name="list" item="vo"}
            <div style="cursor: pointer;margin-left:10px;display:inline-block;padding:2px 4px;">
                <div style="color:black;text-align:right" onclick="del('{:url('Goods/del_pic')}','{$vo.id}');"><i class="layui-icon">&#x1007;</i></div>
                <a href="{$vo.picpath}{$vo.picname}" target="_blank"><img src="{$vo.picpath}x_{$vo.picname}" style="width:200px;"></a>
            </div>
            {/foreach}
            {/empty}
        </div>
    </fieldset>

    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" method="post" action="{:url('Goods/insert_pic')}" enctype="multipart/form-data">
            <input type="hidden" name="gid" value="{$gid}">
            <div class="layui-form-item">
                <!-- <label class="layui-form-label">规格名</label> -->
                <div class="layui-input-inline">
                    <input type="file" name="picname" required  lay-verify="required" autocomplete="off" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <!-- <div class="layui-input-block"> -->
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <!-- </div> -->
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    function del(url,id){
        layer.confirm('确定删除？', {
            icon: 3,
            title:'提示框',
            btn: ['确定','取消'] //按钮
        },function(){
            $.post(url,{id:id},function(data){
                //layer.msg(data)
                //console.log(data);
                //return false;
                layer.msg(data.msg);
                if(data.code == 1){
                    refresh();
                }
            });
        });
    }

    layui.use('form', function(){
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(formDemo)', function(data){
            /*
            <!-- return post(data.form); -->
            <!-- layer.msg(JSON.stringify(data.field)); -->
            <!-- return false; -->
            */
            layer.confirm('确认执行此操作？', {icon: 3, title:'提示'}, function(index){
                $(data.form).ajaxSubmit({
                    success: function(data){
                        //console.log(data);
                        if(data.code == 1){
                            layer.close(index);
                            layer.closeAll();
                            layer.msg(data.msg);
                            refresh();
                        }else{
                            layer.msg(data.msg);
                        }
                    },
                    error: function (){
                        layer.close(index);
                        layer.closeAll();
                        layer.msg("系统正忙");
                        refresh();
                    }
                });
            });
            return false;
        });
    });

</script>